package com.linked.universal.linkedutil;

import java.util.HashMap;
import java.util.Map;

/**
 * 阿拉伯數字轉化為漢字
 * */
public class ArabicToChineseUtils {

    private static Map<Character, Character> digitMap = new HashMap<>();

    static {
        digitMap.put('0', '零');
        digitMap.put('1', '一');
        digitMap.put('2', '二');
        digitMap.put('3', '三');
        digitMap.put('4', '四');
        digitMap.put('5', '五');
        digitMap.put('6', '六');
        digitMap.put('7', '七');
        digitMap.put('8', '八');
        digitMap.put('9', '九');
    }

    public static String convertToChinese(String number) {
        StringBuilder result = new StringBuilder();
        for (char c : number.toCharArray()) {
            if (digitMap.containsKey(c)) {
                result.append(digitMap.get(c));
            } else {
                result.append(c);
            }
        }
        return result.toString();
    }

    public static void main(String[] args) {
        String number = "12345";
        String chineseNumber = convertToChinese(number);
        System.out.println(chineseNumber);
    }
}
